package com.dreamchaser.familydevice.domain;

import lombok.Data;
import lombok.experimental.Accessors;

/***
 *
 *
 * @Author: SJie
 * Date: 2020/2/17 上午10:53
 * Description:
 *
 */
@Data
@Accessors(chain = true)
public class MessageVO {

    /**
     * 状态码
     */
    private int code;

    private String message;

    /**
     * 错误信息
     */
    private String error;

    /**
     * 业务数据
     */
    private Object data;

    private boolean success;

    public MessageVO back(int code, String message) {
        this.code = code;
        this.message = message;
        doSuccess(code);
        return this;

    }

    private void doSuccess(int code) {
        if (code >= 200 && code < 300) {
            this.success = true;
        } else {
            this.success = false;
        }
    }

}
